package parser;
import antlr.RecognitionException;
import antlr.Token;

class Identity extends Expr {
    
    Expr left;
    Expr right;
    
    Identity(Expr left, Expr right) {
        this.left = left;
        this.right = right;
    }
     
    void write(ByteStream out) throws RecognitionException {
        left.write(out);
        right.write(out);
        out.write(Opcodes.IS);
    }
    
    void writeLHS(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot assign to binary operator");
    }
        
    void delete(ByteStream out) throws RecognitionException {
        throw new RecognitionException("Cannot delete rvalue");
    }
        
    Patch branch(boolean onTrue, ByteStream out) throws RecognitionException {
        write(out);
        return out.branch(onTrue ? Opcodes.ON_TRUE : Opcodes.ON_FALSE);
    }
   
}
